
#@layout()
#define css()
#@layout_css?()
<link rel="stylesheet" href="#(CPATH)/static/components/datepicker/css/bootstrap-datepicker3.min.css">
#end
#define script()
#@layout_script?()
<script src="#(CPATH)/static/components/datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="#(CPATH)/static/components/datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script>
    $("input[hint='date']").datepicker({
        format: 'yyyy-mm-dd',
        language: 'zh-CN'
    });

  function doSubmit() {
      $.post("/admin/music/jpress_addon_music/doSave",
          {
              "jpressAddonMusic.json":$('#textJson').text(),
              "jpressAddonMusic.id":$('#entryId').val()
          },
          function(data,status){
              toastr.success('内容保存成功。');
      });
  }

    $("#submit").on("click", function () {
        doSubmit();
        return false;
    })

    $("#getJson").on("click", function () {
        $.ajax({
            //请求方式
            type : "get",
            //请求地址
            url : "/admin/music/jpress_addon_music/getJson?id="+$("#wyyId").val(),
            //请求成功
            success : function(result) {
                $("#textJson").text(result.json);
            },
            //请求失败，包含具体的错误信息
            error : function(e){
                alert(e.responseText);
                console.log(e.status);
                console.log(e.responseText);
            }
        });
    })
    </script>
#end

#define content()
<div class="content-wrapper">

    <section class="content-header">
        <h1>
            编辑<small>Edit</small>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-xs-12">
                <div class="box box-primary">
                    <div class="box-header ">
                        <h3 class="box-title"></h3>
                    </div>
                    <form class="form-horizontal form-setting" autocomplete="off"
                          action="/admin/music/jpress_addon_music/doSave"
                          method="POST" id="form">

                        <div class="box-body ">
	                         <input type="hidden" id="entryId" name="jpressAddonMusic.id" value="#(jpressAddonMusic.id ??)">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">歌单ID</label>
                                <div class="col-sm-6">
                                    <input type="text" id="wyyId" placeholder="请输入网易云歌单ID">
                                    <input type="button" value="发射..." id="getJson" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">json</label>
                                <div class="col-sm-6">
                                    <div id="textJson" contenteditable="true" style="width: 100%;height: 300px;overflow: auto;">#(jpressAddonMusic.json ??)</div>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <div class="col-sm-offset-2 col-sm-10 submit-block">
                                <div class="box-submit">
                                    <button id="submit" type="button" class="btn btn-primary">提交</button>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>
            </div>
        </div>

    </section>

</div>
#end